package sch.frog.behavioral.memento;

public class MementoDemo {

    public static void main(String[] args){
        Originator originator = new Originator();
        Caretaker caretaker = new Caretaker();

        originator.run();
        caretaker.addMemento(originator.createMemento());

        originator.run();
        caretaker.addMemento(originator.createMemento());

        originator.run();
        caretaker.addMemento(originator.createMemento());

        originator.run();
        caretaker.addMemento(originator.createMemento());

        Memento memento = null;
        while((memento = caretaker.popMemento()) != null){
            originator.restoreMemento(memento);
            System.out.println(originator.getStatus());
        }

    }

}
